<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      xmlns:sec="http://www.thymeleaf.org/extras/spring-security"
      layout:decorate="~{layout/layout}">
<head>

</head>
<body>
<div layout:fragment="content">

    <h1 th:text="#{licence.add}">厂商证照录入</h1>
    <div>
        <form id="itemForm" class="form-horizontal" th:action="@{/supplier/edit/}" th:object="${supplier}" method="post" enctype="multipart/form-data">
            <input type="hidden" th:field="*{id}"/>
            <div class="form-group">
                <label for="name" class="col-sm-1 control-label" th:text="#{supplier.name}">厂商</label>
                <div class="col-sm-4">
                    <input type="text" th:field="*{name}" class="form-control" th:readonly="${supplier.id != null}" th:placeholder="#{supplier.name}"/>
                    <p th:if="${#fields.hasErrors('name')}" th:errors="*{name}" class="error">厂商错误</p>
                </div>

                <label for="lastDate" class="col-sm-2 control-label" th:text="#{supplier.lastDate}">报告日期</label>
                <div class="col-sm-2">
                    <input type="text" th:field="*{lastDate}" class="form-control" th:placeholder="#{supplier.lastDate}"/>
                    <p th:if="${#fields.hasErrors('lastDate')}" th:errors="*{lastDate}" class="error">报告日期</p>
                </div>
            </div>
            <div class="form-group">
                <label for="state" class="col-sm-1 control-label" th:text="#{state}">状态</label>
                <div class="col-sm-1">
                    <input type="text" th:field="*{state}" min="0" class="form-control" th:placeholder="#{state}"/>
                    <p th:if="${#fields.hasErrors('state')}" th:errors="*{state}" class="error">状态错误</p>
                </div>
                <label class="col-sm-2 control-label" th:text="#{uploadImage}">上传图片(可多选)</label>
                <div class="col-sm-4">
                    <input type="file" name="file" accept="image/jpeg,image/gif,image/png,image/bmp" multiple/>
                </div>
                <div class="col-sm-1">
                    <input type="submit" th:value="#{submit}" class="btn btn-info"/>
                </div>
                <div class="col-sm-1">
                    <a href="/supplier/list" th:href="@{/supplier/list}" class="btn btn-info" th:text="#{back}">返回</a>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-3" th:each="imageUrl, stat : ${imageUrlList}">
                    <div><a th:href="@{'/' + ${supplier.name} + '/' + ${imageUrl}}" target="_blank">
                        <img width="200" height="200" th:src="@{'/' + ${supplier.name} + '/' + ${imageUrl}}"/>
                        </a>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>
<th:block layout:fragment="pagescript">
    <script th:src="@{/js/jquery-ui/jquery-ui.datepicker-zh-CN.js}"></script>
    <script th:src="@{/js/jquery-viladate/jquery.validate.min.js}"></script>
    <script th:src="@{/js/jquery-viladate/messages_zh.min.js}"></script>
    <script th:inline="javascript">
        $(document).ready(function () {
            $("#lastDate").datepicker({
                changeMonth: true,
                changeYear: true,
                showWeek: true,
                firstDay: 0,
                showOtherMonths: true,
                selectOtherMonths: true,
                showAnim: 'slideDown',
                showButtonPanel: true
            });
            $("#itemForm").validate({
                onsubmit: true,

                rules: {

                },
                messages: {

                },
                submitHandler: function (form) {
                    form.submit();
                },
                invalidHandler: function (form, validator) {
                    return false;
                }
            });
        });
    </script>

</th:block>
</body>
</html>
